package com.base.vistter.iframe.inverter.controller;

import com.base.vistter.iframe.bean.Result;
import com.base.vistter.iframe.entity.InverterAlarm;
import com.base.vistter.iframe.exception.IframeException;
import com.base.vistter.iframe.service.InverterAlarmService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

@RestController
@Slf4j
@RequestMapping("/alarm")
public class InverterAlarmController {
    @Resource(name = "inverterAlarmService")
    private InverterAlarmService inverterAlarmService;

    @GetMapping("/recover")
    public Result<Boolean> recover(Integer id, Integer alarmId) throws IframeException {
        InverterAlarm inverterAlarm = new InverterAlarm();
        inverterAlarm.setId(id);
        inverterAlarm.setEndTime(new Date());
        inverterAlarm.setStatus(2);
        return Result.ok(inverterAlarmService.update(inverterAlarm));
    }

}
